<?php

namespace app\index\service;

use app\common\model\ToolModel;
use app\common\service\MotanService;
use think\Cache;

class HandoverreviewService
{
    static public function getRule()
    {
        $list=ToolModel::select('setting_product_rule','','','id asc');
        $r=ToolModel::find('setting_product_rule','','','modification_time desc');
        return returnArr(1,'',['list'=>$list,'r'=>$r]);
    }
    static public function edit($param){
        if(!empty($param['status'][0])&&$param['status'][0]=='on'){
            $param['status'][0]=1;
            if(empty($param['describe'][0])){
                return returnArr('2',"交接类型不能为空");
            }
        }else{
            $param['status'][0]=2;
        }
        if(!empty($param['status'][1])&&$param['status'][1]=='on'){
            $param['status'][1]=1;
        }else{
            $param['status'][1]=2;
        }
        $data1=[];
        $data2=[];
        if(!empty($param['describe'][0])){
            $data1['describe']=join(',',explodeStr($param['describe'][0]));
        }else{
            $data1['describe']=$param['describe'][0];
        }
        $data1['status']=$param['status'][0];
        $data1['operator']=CN_NAME;
        ToolModel::updateData(['id'=>1],$data1,'setting_product_rule');
        $data2['make_type']=$param['make_type'][1];
        $data2['symbol']=$param['symbol'][1];
        $data2['num']=$param['num'][1];
        $data2['status']=$param['status'][1];
        $data2['operator']=CN_NAME;
        ToolModel::updateData(['id'=>2],$data2,'setting_product_rule');
        return returnArr();
    }
}